var t = getApp();

Page({
    data: {
        name: "",
        card: "",
        card_type: "",
        identity: "",
        mobile: "",
        cvv2: "",
        valid_day: "",
        cardShow: !1,
        radioCard: "",
        bankCard: [ {
            name: "储蓄卡",
            id: 1
        }, {
            name: "信用卡",
            id: 2
        } ],
        timeShow: !1,
        maxDate: new Date().getTime(),
        currentDate: new Date().getTime(),
        to: "",
        option: ""
    },
    onLoad: function(t) {
        wx.setNavigationBarTitle({
            title: "添加银行卡"
        }), t.to && (this.data.to = t.to), t.option && (this.data.option = option.option);
    },
    onReady: function() {},
    cardShowClose: function() {
        this.setData({
            cardShow: !1
        });
    },
    childParams: function(t) {
        var a = t.currentTarget.dataset.key;
        "card_type" == a ? this.setData({
            cardShow: !0
        }) : "valid_day" == a && this.setData({
            timeShow: !0
        });
    },
    onClickRight_close: function(t) {
        this.setData({
            timeShow: !1
        });
    },
    onClickRight_cardShow: function(t) {
        this.setData({
            card_type: "储蓄卡" == this.data.radioCard ? 1 : 2,
            cardShow: !1
        });
    },
    onClickRight_timeShow: function(t) {
        var a = t.detail;
        this.setData({
            valid_day: this.timestampToTime(a),
            timeShow: !1
        });
    },
    timestampToTime: function(t) {
        if (!Number(t) || "" == t) return "";
        var a = new Date(t), i = a.getFullYear(), e = a.getMonth() + 1 < 10 ? "0" + (a.getMonth() + 1) : a.getMonth() + 1;
        return "".concat(e).concat(i);
    },
    onChange: function(t) {
        var a = t.detail;
        this.setData({
            radioCard: a
        });
    },
    checkJson: function() {
        if (t._isTextEmpty(this.data.card_type)) return t.tips("请选择银行卡类型"), !1;
        if (t._isTextEmpty(this.data.card)) return t.tips("请输入卡号"), !1;
        if (t._isTextEmpty(this.data.mobile)) return t.tips("请输入银行卡预留手机号"), !1;
        if (t._isTextEmpty(this.data.name)) return t.tips("请输入持卡人姓名"), !1;
        if (t._isTextEmpty(this.data.identity)) return t.tips("请输入身份证"), !1;
        if (2 == this.card_type) {
            if (t._isTextEmpty(this.data.valid_day)) return t.tips("请选择月份/年份"), !1;
            if (t._isTextEmpty(this.data.cvv2)) return t.tips("请选择月份/年份"), !1;
        }
        return !0;
    },
    confirmBtn: function() {
        var a = this;
        if (this.checkJson()) {
            var i = t.getNetAddresss("plugin.eplus-pay.frontend.card.bindCardApply"), e = {
                card_type: this.data.card_type,
                card_no: this.data.card,
                phone: this.data.mobile,
                name: this.data.name,
                identity_no: this.data.identity
            };
            2 == this.data.card_type && (e.validate = this.data.valid_day, e.cvv2 = this.data.cvv2), 
            t._getNetWork({
                url: i,
                data: e,
                success: function(i) {
                    var e = i.data;
                    1 == e.result ? (console.log(e), wx.showModal({
                        showCancel: !1,
                        content: e.msg,
                        success: function() {
                            "SilverBankListwisdom" == a.data.to ? wx.redirectTo({
                                url: "/packageF/silverPointPay/SilverBankList/SilverBankList"
                            }) : "wisdomBindTask" == a.data.to ? wx.redirectTo({
                                url: "/packageF/others/wisdom/wisdomBindTask/wisdomBindTask"
                            }) : wx.navigateBack({
                                delta: 1
                            });
                        }
                    })) : t.tips(e.msg);
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});